home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Plus 2004 #11
/
Amiga Plus CD - 2004 - No. 11.iso
/
AmiSoft
/
Comm
/
net
/
SLH.lha
/
SLH
/
slh
next >
Wrap
Text File
|
2004-08-08
|
7KB
|
225 lines
/* Samba's little Helper slh.rexx v0.3 */
signal on halt
signal on break_c
options results
call Init
call createApp
call handleApp
/***********************************************************************/
Init: procedure expose global.
l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
if AddLibrary("rexxsupport.library","rxmui.library")~=0 then exit
if AddLibrary("rxasl.library")~=0 then exit
call ReadToolTypes("SLH","ttyp")
global.path = "Samba:bin"
global.ipcounter=0
do a = 0 to ttyp.num - 1
if ttyp.a.Active = 1 then do
if upper(ttyp.a) = "SAMBABINPATH" then global.path = ttyp.a.Value
else if upper(ttyp.a) = "ADDIP" then do
global.ipcounter = global.ipcounter+1
nr = global.ipcounter
global.ipnumber.nr = ttyp.a.Value
global.ipnames.nr = ttyp.a.Value
end
else do
pa = upper(ttyp.a)
if index(ttyp.a,"/") > 0 then global.pass.pa = ttyp.a.Value
end
end
end
call SetRxMUIStack(64000)
return
/***********************************************************************/
HandleApp: procedure expose global.
ctrl_c=2**12
do forever
call NewHandle("app","h",ctrl_c)
if and(h.signals,ctrl_c)>0 then exit
if h.EventFlag then
select
when h.event="QUIT" then exit
otherwise interpret h.event
end
end
end
/***********************************************************************/
createApp: procedure expose global.
app.Title="SLH"
app.Version="$VER: 0.3 Samba's Little Helper (08.08.2004)"
app.Copyright="No Copyright by Robin"
app.Author="Robin Hueskes robin@amiganiac.net"
app.Description="Samba's Little Helper"
app.Base="SLH"
app.menustrip="strip"
strip.class="Menustrip"
strip.0="mproject"
mproject.Title="Project"
mproject.class="menu"
mproject.0=menuitem("mabout","?\About...")
mproject.1=menuitem("maboutrxmui","About RxMUI...")
mproject.2=menuitem("maboutmui","!\About MUI...")
mproject.3=menuitem("","BAR")
mproject.4=menuitem("mhide","I\Iconify")
mproject.5=menuitem("","BAR")
mproject.6=menuitem("mquit","Q\Quit")
app.SubWindow.0="win"
win.class="Window"
win.title="Samba's Little Helper"
win.ID="PWIN"
win.Contents="dgroup"
dgroup.class="group"
dgroup.0="iv"
iv.class = "NListView"
iv.list = "iw"
iw.class = "nlist"
iw.title = "Server|Domain|IP|Share|Task"
iw.format = ",,,,"
dgroup.1=button("c_but1","_Scan")
call NewObj("APPLICATION","APP")
call Notify("win","CloseRequest",1,"app","ReturnID","QUIT")
call Notify("mabout","menutrigger","Everytime","app","about","win")
call Notify("maboutrxmui","menutrigger","everytime","app","aboutrxmui","win")
call Notify("maboutmui","menutrigger","everytime","app","aboutmui","win")
call Notify("mhide","menutrigger","everytime","app","set","iconified",1)
call Notify("mquit","menutrigger","everytime","app","ReturnID","QUIT")
call Notify("c_but1","pressed",0,"app","Return","call MD")
call Notify("iw","DoubleClick","EveryTime","app","Return","call CD()")
call MD()
call set("win","open",1)
return
/***********************************************************************/
CD: procedure expose global.
call DoMethod("iw","GetEntry","Active","line")
parse var line server"|"domain"|"ip"|"share"|"tnr
if datatype(tnr,"N") then address command "break c" tnr
else do
parse var tnr suser":"spass
if tnr = "Not mounted" then address command "run >nil: smbfs volume="server"_"share "workgroup="domain "service=//"server"/"share
else address command "run >nil: smbfs user="suser" password="spass" volume="server"_"share "workgroup="domain "service=//"server"/"share
end
address command "wait"
call MD()
return
MD: procedure expose global.
call DoMethod("iw","Clear")
path=global.path
tmp = rmh_GetUniqueID()
tmp = "pipe:slh_"||tmp
com = "status >"tmp
address command com
if open('temp',tmp,'R') then do
do while ~EOF('temp')
nix = readln('temp')
parse var nix "Process " processnr": Loaded as command: " comline
if index(upper(comline),"SMBFS") > 0 then do
parse var comline smbfs" '//"sharename"'"
activeshare.sharename = processnr
end
end
end
close('temp')
tmp = rmh_GetUniqueID()
tmp = "pipe:slh_"||tmp
com = rmh_addpart(path,'nmblookup')
com = com "-d 0 -T * >"||tmp
address command com
if open('temp',tmp,'R') then do
ipcount = global.ipcounter
if ipcount > 0 then do a = 1 to ipcount
ipnr.a = global.ipnumber.a
ipname.a = global.ipnames.a
end
do while ~EOF('temp')
nix = readln('temp')
if index(nix,"<00>") > 0 then do
parse var nix name", "ip " " info
ipcount = ipcount + 1
ipnr.ipcount = ip
ipname.ipcount = name
end
end
call close('temp')
tmp = rmh_GetUniqueID()
tmp = "pipe:slh_"||tmp
com = rmh_addpart(path,'nmblookup')
com = com "-d 0 -T -M - >"||tmp
address command com
if open('temp',tmp,'R') then do
do while ~EOF('temp')
nix = readln('temp')
if index(nix,"<01>") > 0 then do
parse var nix name", "ip " " info
ipcount = ipcount + 1
ipnr.ipcount = ip
ipname.ipcount = name
end
end
call close('temp')
end
if ipcount > 0 then do
do a = 1 to ipcount
mode = 0
oldmode = 0
tmp = rmh_GetUniqueID()
tmp = "pipe:slh_"||tmp
com = rmh_addpart(path,'smbclient')
com = com "-N -L" ipnr.a ">"||tmp
address command com
if open('temp',tmp,'R') then do
do while ~EOF('temp')
nix = readln('temp')
if index(upper(nix),"DOMAIN") = 1 then do
parse var nix "Domain=["info_domain"] OS=["info_os"] Server=["info_server"]"
end
else if index(upper(strip(compress(nix))),"SHARENAMETYPECOMMENT") > 0 then mode=1
else if index(upper(strip(compress(nix))),"SERVERCOMMENT") > 0 then mode=2
else if index(upper(strip(compress(nix))),"WORKGROUPMASTER") > 0 then mode=3
if oldmode ~= mode then do
nix = readln('temp')
nix = readln('temp')
oldmode = mode
end
if mode = 1 then do
parse var nix info_share info_type info_comment
info_share = strip(info_share)
info_share = strip(info_share,'L',x2c(09))
info_type = strip(info_type)
info_comment = strip(info_comment)
if upper(info_type) = 'DISK' then do
sn = ipname.a"/"info_share
su = upper(sn)
tnr = global.pass.su
if index(tnr,"GLOBAL.PASS.") > 0 then tnr = "Not mounted"
ipn = ipname.a
if datatype(activeshare.sn,"N") then do
tnr = activeshare.sn
ipn = ParseText("%b"ipname.a)
end
ili = ipn"|"info_domain"|"ipnr.a"|"info_share"|"tnr
call DoMethod("iw","INSERT",ili,"Sorted")
end
end
end
call close('temp')
end
end
end
end
return